package com.atguigu.gmall.order.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.order.entity.OrderInfo;
import com.atguigu.gmall.model.order.vo.OrderConfirmVo;
import com.atguigu.gmall.order.biz.OrderService;
import com.atguigu.gmall.order.service.OrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:lyd
 **/
@RestController
@RequestMapping("/api/inner/order")
public class OrderRpcController {

    @Autowired
    OrderService orderService;
    @Autowired
    OrderInfoService orderInfoService;
    @GetMapping("/orderconfirm")
    public Result<OrderConfirmVo> orderConfirm() {
        OrderConfirmVo orderConfirmVo = orderService.getOrderConfirmVo();
        return Result.ok(orderConfirmVo);
    }

    /**
     * 根据订单id查询订单信息
     * @param orderId
     * @return
     */
    @GetMapping("/orderinfo/{orderId}")
    public Result<OrderInfo> getOrderInfoById(@PathVariable("orderId") Long orderId) {
        OrderInfo orderInfo = orderInfoService.findOrderInfoById(orderId);
        return Result.ok(orderInfo);
    }
}
